<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
			//手写bing方法：
      ~(function () {
        function bind(context, ...args) {
					let _this = this;
          context = context == undefined ? window : context;
          let type = typeof context;
          if (!/^(object|function)$/.test(type)) {
            if (/^(symbol|bigint)$/.test(type)) {
              context = Object(context);
            } else {
              context = new context.constructor(context);
            }
          }
					return function anonymous(...innerArgs){
						_this.call(context, ...args.concat(innerArgs));
					}
        }
        Function.prototype.bind = bind;
      })();
      var obj = {
        name: "gmx",
      };

      function func() {
        console.log(this, arguments);
      }

      document.body.onclick = func.bind(obj, 100, 200);
    </script>
  </body>
</html>
